package main

func main() {

}

func findPoisonedDuration(timeSeries []int, duration int) (res int) {
	n := len(timeSeries)
	res = duration
	for i := 1; i < n; i++ {
		if timeSeries[i]-timeSeries[i-1] > duration {
			res += duration
		} else {
			res += timeSeries[i] - timeSeries[i-1]
		}
	}
	return
}
